<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong> {{ sheng }} </strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: sun === 'all' }"
          @click="activeFn('all')"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: sun === 'active' }"
          @click="activeFn('active')"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: sun === 'over' }"
          @click="activeFn('over')"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" v-show="cls" @click="clsFn">
      清除已完成
    </button>
  </footer>
</template>

<script>
export default {
  props: ["sheng", "list"],
  data() {
    return {
      sun: "all",
    };
  },
  methods: {
    //子传父清除数据
    clsFn() {
      this.$emit("clsFn");
    },
    //高亮
    activeFn(all) {
      this.sun = all;

      this.$emit("activeFn", all);
    },
  },
  computed: {
    //清除完成的
    cls() {
      return this.list.some((item) => item.isDone);
    },
  },
};
</script>
